﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RonYee.Models;

namespace RonYee.Service
{
    public static class RandomNumberTo
    {
        //--Generate a random number--And Check the number

        private static char[] constant =   
        {     
            'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'   
        };
        public static string GenerateRandomNumber()
        {
            //string dNow = DateTime.Now.ToString().Trim().Replace("-", "").Replace(":", "").Replace(" ", "");
            string NoDate = DateTime.Now.ToString("yyMMdd");
            int Length = 6;

            System.Text.StringBuilder newRandom = new System.Text.StringBuilder(62);
            Random rd = new Random();
            for (int i = 0; i < Length; i++)
            {
                newRandom.Append(constant[rd.Next(62)]);
            }
            string No = "N" + NoDate + newRandom.ToString();

            return No;

        }


        private static char[] constantother = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };

        public static string RandomNumberToName()
        {
            int Length = 12;

            System.Text.StringBuilder newRandom = new System.Text.StringBuilder(10);
            Random rd = new Random();
            for (int i = 0; i < Length; i++)
            {
                newRandom.Append(constantother[rd.Next(10)]);
            }
            string No = newRandom.ToString();
            return No;

        }


    }
}
